import {ElMessage} from "element-plus"
import {getanswer,getdescanswer,setaccept} from "../../service/answer"
const answer = {
  namespaced: true,
  state() {
    return {
         issue : [
            // {
            //   info: {
            //     icon: require("@/assets/images/log.png"),
            //     name: "小张",
            //     time: "三天前",
            //   },
            //   problem: "黑洞是怎么构成的",
            //   particulars: {
            //     visit: 99,
            //     answer: 100,
            //     attention: 999,
            //   },
            // },
            // {
            //   info: {
            //     icon: require("@/assets/images/log.png"),
            //     name: "张三",
            //     time: "五天前",
            //   },
            //   problem: "怎么才能赚钱",
            //   particulars: {
            //     visit: 9999,
            //     answer: 100000,
            //     attention: 999999,
            //   },
            // },
          ]
    }
  },
  mutations: {
    changedata(state, data) {
      state.data = data
    },
    changedatalist(state, datalist) {
      state.datalist = datalist
    },
    changeissue(state,res){
      state.issue = res
    }
  },
  actions: {
    async getanswer ({commit}) {
       const res = await getanswer()
       commit('changeissue',res)
    } ,
    // 按照 赏金降序来查询文章 
    async getdescanswer ({commit},) {
      const res = await getdescanswer()
      commit('changeissue',res)
    },
    //用户采纳回答
    async setaccept ({commit},id) {
      console.log(commit,id,'查看ID');
      const res = await setaccept(id)
      if(res) {
        ElMessage.success({
          message:"采取成功"
        })
      }
    } 
  },
  getters:{

  },
  modules: {}
}
export default answer
